# 计算从0到num的二进制各有多少个1，例如 [0,1,2] 得到 [0,1,1]
def countBits(num):
    res = [0] * num
    for i in range(1, num):
        res[i] = res[i & (i - 1)] + 1
    return res


if __name__ == '__main__':
    print(countBits(199))
